package com.springboot.springboot4.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName:
 * @author: CKC
 * @DateTime: 2021/1/30 14:29
 */
@Configuration
public class MybatisConfig {
    @Bean
    public MybatisPlusInterceptor paginationInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor=new MybatisPlusInterceptor();
        /**
         * 设置请求的页面大于最大页后操作，true调回到首页，false 继续请求默认false
         * paginationInterceptor.setOverFlow(false ) ;
         * 设置最大单页限制数量，默认50日条，-1不受限制
         * paginationInterceptor.setLimit(500) ;
         * 开启count 的join优化,只针对部分Left join
         */
        //这是分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor =new PaginationInnerInterceptor();
        
        paginationInnerInterceptor.setOverflow(true);
        paginationInnerInterceptor.setMaxLimit(500L);
        
        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return mybatisPlusInterceptor;
    }
}
